
package Interfaz;

import Datos.PrendaDB;
import Negocio.Conjunto;
import Negocio.Conjunto_Prenda;
import Negocio.Lista_Prenda;
import Negocio.Lista_login;
import Negocio.Login;
import Negocio.Prenda;
import Negocio.Usuario;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

public class Prendas extends javax.swing.JFrame {
    Principal princi;
    Prenda prenda = new Prenda();
    Login login = new Login();
    Usuario usuario = new Usuario();
    Lista_Prenda listaPrenda = new Lista_Prenda();
    Lista_login listaLogin = new Lista_login();    
    PrendaDB prdb = new PrendaDB();
    ArrayList prendas = new ArrayList();
    Conjunto_Prenda cp = new Conjunto_Prenda();

    public Prendas() {
        initComponents();
        setDefaultCloseOperation(0);
        
    }

    private void LimpiarTabla(){
       DefaultTableModel temp = (DefaultTableModel) tblPrendas.getModel();
        tblPrendas.setModel(temp);
    }
    
   
    private void actualizarPrendaClasificacion(String cedula, int id){
        listaPrenda.listarClasificacion(cedula, id);
        ArrayList prendas = new ArrayList();
        prendas = listaPrenda.getPrendas();
        DefaultTableModel temp = (DefaultTableModel) tblPrendas.getModel();
        for (int i = tblPrendas.getRowCount() - 1; i >= 0; i--) {
            temp.removeRow(i);
        }
        for (int i = 0; i < prendas.size(); i++) {
            Prenda prend = new Prenda();
            prend = (Prenda) prendas.get(i);
            Object nuevo[] = {prend.getCodigo(), prend.getDescripcion(), prend.getFecha_adquisicion(), prend.getColor(), prend.getNum_usos_total()};
            temp.addRow(nuevo);
        }
        tblPrendas.setModel(temp);
    }
    
    private void actualizarPrendaConDefectos(String cedula){
            LimpiarTabla();
        listaPrenda.listarConDefectos(cedula);
        ArrayList prendas = new ArrayList();
        prendas = listaPrenda.getPrendas();
        DefaultTableModel temp = (DefaultTableModel) tblPrendas.getModel();
        for (int i = tblPrendas.getRowCount() - 1; i >= 0; i--) {
            temp.removeRow(i);
        }
        for (int i = 0; i < prendas.size(); i++) {
            Prenda prend = new Prenda();
            prend = (Prenda) prendas.get(i);
            Object nuevo[] = {prend.getCodigo(), prend.getDescripcion(), prend.getFecha_adquisicion(), prend.getColor(), prend.getNum_usos_total()};
            temp.addRow(nuevo);
        }
        tblPrendas.setModel(temp);
    }
    
    
    private void actualizarPrendaCompatidas(String cedula){
            LimpiarTabla();
        listaPrenda.listarCompartidas(cedula);
        ArrayList prendas = new ArrayList();
        prendas = listaPrenda.getPrendas();
        DefaultTableModel temp = (DefaultTableModel) tblPrendas.getModel();
        for (int i = tblPrendas.getRowCount() - 1; i >= 0; i--) {
            temp.removeRow(i);
        }
        for (int i = 0; i < prendas.size(); i++) {
            Prenda prend = new Prenda();
            prend = (Prenda) prendas.get(i);
            Object nuevo[] = {prend.getCodigo(), prend.getDescripcion(), prend.getFecha_adquisicion(), prend.getColor(), prend.getNum_usos_total()};
            temp.addRow(nuevo);
        }
        tblPrendas.setModel(temp);
    }
    
    private void actualizarPrendaIndividuales(String cedula){
            LimpiarTabla();
        listaPrenda.listarIndividuales(cedula);
        ArrayList prendas = new ArrayList();
        prendas = listaPrenda.getPrendas();
        DefaultTableModel temp = (DefaultTableModel) tblPrendas.getModel();
        for (int i = tblPrendas.getRowCount() - 1; i >= 0; i--) {
            temp.removeRow(i);
        }
        for (int i = 0; i < prendas.size(); i++) {
            Prenda prend = new Prenda();
            prend = (Prenda) prendas.get(i);
            Object nuevo[] = {prend.getCodigo(), prend.getDescripcion(), prend.getFecha_adquisicion(), prend.getColor(), prend.getNum_usos_total()};
            temp.addRow(nuevo);
        }
        tblPrendas.setModel(temp);
    }
    
    private void actualizarPrendaSinDefectos(String cedula){
            LimpiarTabla();
        listaPrenda.listarSinDefectos(cedula);
        ArrayList prendas = new ArrayList();
        prendas = listaPrenda.getPrendas();
        DefaultTableModel temp = (DefaultTableModel) tblPrendas.getModel();
        for (int i = tblPrendas.getRowCount() - 1; i >= 0; i--) {
            temp.removeRow(i);
        }
        for (int i = 0; i < prendas.size(); i++) {
            Prenda prend = new Prenda();
            prend = (Prenda) prendas.get(i);
            Object nuevo[] = {prend.getCodigo(), prend.getDescripcion(), prend.getFecha_adquisicion(), prend.getColor(), prend.getNum_usos_total()};
            temp.addRow(nuevo);
        }
        tblPrendas.setModel(temp);
    }
    
    
        private void actualizarPrendaMasUsos(String cedula){
            LimpiarTabla();
        listaPrenda.listarMasUsos(cedula);
        ArrayList prendas = new ArrayList();
        prendas = listaPrenda.getPrendas();
        DefaultTableModel temp = (DefaultTableModel) tblPrendas.getModel();
        for (int i = tblPrendas.getRowCount() - 1; i >= 0; i--) {
            temp.removeRow(i);
        }
        for (int i = 0; i < prendas.size(); i++) {
            Prenda prend = new Prenda();
            prend = (Prenda) prendas.get(i);
            Object nuevo[] = {prend.getCodigo(), prend.getDescripcion(), prend.getFecha_adquisicion(), prend.getColor(), prend.getNum_usos_total()};
            temp.addRow(nuevo);
        }
        tblPrendas.setModel(temp);
    }
        
         private void actualizarPrendaMenosUsos(String cedula){
             LimpiarTabla();
        listaPrenda.listarMenosUsos(cedula);
        ArrayList prendas = new ArrayList();
        prendas = listaPrenda.getPrendas();
        DefaultTableModel temp = (DefaultTableModel) tblPrendas.getModel();
        for (int i = tblPrendas.getRowCount() - 1; i >= 0; i--) {
            temp.removeRow(i);
        }
        for (int i = 0; i < prendas.size(); i++) {
            Prenda prend = new Prenda();
            prend = (Prenda) prendas.get(i);
            Object nuevo[] = {prend.getCodigo(), prend.getDescripcion(), prend.getFecha_adquisicion(), prend.getColor(), prend.getNum_usos_total()};
            temp.addRow(nuevo);
        }
        tblPrendas.setModel(temp);
    }
    
    private void actualizarPrendaRangoFechas(String cedula, String fechaInicio, String fechaFin){
        LimpiarTabla();
        listaPrenda.listarRangoFechas(cedula, fechaInicio, fechaFin);
        ArrayList prendas = new ArrayList();
        prendas = listaPrenda.getPrendas();
        DefaultTableModel temp = (DefaultTableModel) tblPrendas.getModel();
        for (int i = tblPrendas.getRowCount() - 1; i >= 0; i--) {
            temp.removeRow(i);
        }
        for (int i = 0; i < prendas.size(); i++) {
            Prenda prend = new Prenda();
            prend = (Prenda) prendas.get(i);
            Object nuevo[] = {prend.getCodigo(), prend.getDescripcion(), prend.getFecha_adquisicion(), prend.getColor(), prend.getNum_usos_total()};
            temp.addRow(nuevo);
        }
        tblPrendas.setModel(temp);
    }
    
    private void actualizarConjuntoPrenda(ArrayList lis){
        DefaultTableModel temp = (DefaultTableModel) tblNuevoConjunto.getModel();
        for (int i = tblNuevoConjunto.getRowCount() - 1; i >= 0; i--) {
            temp.removeRow(i);
        }
        for (int i = 0; i < lis.size(); i++) {
            Prenda otroPrenda = new Prenda();
            otroPrenda = (Prenda) lis.get(i);
            Object nuevo[] = {otroPrenda.getCodigo(), otroPrenda.getDescripcion(), otroPrenda.getFecha_adquisicion()};
            temp.addRow(nuevo);
        }
        tblNuevoConjunto.setModel(temp);
    }
    
    private void insertarPrendaTabla(Prenda prenda){
        LimpiarTabla();
        DefaultTableModel temp = (DefaultTableModel) tblPrendas.getModel();
        for (int i = tblPrendas.getRowCount() - 1; i >= 0; i--) {
            temp.removeRow(i);
        }
        
        Object nuevo[] = {prenda.getCodigo(), prenda.getDescripcion(), prenda.getFecha_adquisicion(), prenda.getColor(), prenda.getNum_usos_total()};
        temp.addRow(nuevo);
            
        tblPrendas.setModel(temp);
    }
    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        grupoatributos = new javax.swing.ButtonGroup();
        grupodefectos = new javax.swing.ButtonGroup();
        grupocompartidas = new javax.swing.ButtonGroup();
        grupousados = new javax.swing.ButtonGroup();
        jLabel1 = new javax.swing.JLabel();
        jPanel7 = new javax.swing.JPanel();
        jPanel6 = new javax.swing.JPanel();
        rdCodigo = new javax.swing.JRadioButton();
        rdDescripcion = new javax.swing.JRadioButton();
        rdAdquisicion = new javax.swing.JRadioButton();
        btnBuscarAtributo = new javax.swing.JButton();
        txtAtributos = new javax.swing.JTextField();
        jPanel8 = new javax.swing.JPanel();
        btnBuscarClasificador = new javax.swing.JButton();
        txtClasificador = new javax.swing.JTextField();
        jPanel9 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        btnFechas = new javax.swing.JButton();
        txtFechaInicio = new javax.swing.JTextField();
        txtFechaFin = new javax.swing.JTextField();
        jPanel10 = new javax.swing.JPanel();
        rdcon = new javax.swing.JRadioButton();
        rdsin = new javax.swing.JRadioButton();
        jButton6 = new javax.swing.JButton();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tblPrendas = new javax.swing.JTable();
        jButton2 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jButton8 = new javax.swing.JButton();
        jButton9 = new javax.swing.JButton();
        jButton10 = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        tblNuevoConjunto = new javax.swing.JTable();
        jButton11 = new javax.swing.JButton();
        jButton12 = new javax.swing.JButton();
        jPanel11 = new javax.swing.JPanel();
        rdcompartidas = new javax.swing.JRadioButton();
        rdindividuales = new javax.swing.JRadioButton();
        jButton7 = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        rdmasusados = new javax.swing.JRadioButton();
        rdmenosusados = new javax.swing.JRadioButton();
        btnusos = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        lblCedulaUs = new javax.swing.JLabel();
        lblApodo = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
        jLabel1.setText("Buscador de Prendas");

        jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder("Atributos"));

        grupoatributos.add(rdCodigo);
        rdCodigo.setText("Codigo");
        rdCodigo.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);

        grupoatributos.add(rdDescripcion);
        rdDescripcion.setText("Descripcion");
        rdDescripcion.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);

        grupoatributos.add(rdAdquisicion);
        rdAdquisicion.setText("Fecha de Adquisicion");
        rdAdquisicion.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);

        btnBuscarAtributo.setText("Buscar");
        btnBuscarAtributo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBuscarAtributoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(rdCodigo)
                            .addComponent(rdDescripcion)
                            .addComponent(rdAdquisicion)))
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addGap(48, 48, 48)
                        .addComponent(btnBuscarAtributo))
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(txtAtributos, javax.swing.GroupLayout.PREFERRED_SIZE, 156, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(rdCodigo)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(rdDescripcion)
                .addGap(3, 3, 3)
                .addComponent(rdAdquisicion)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(txtAtributos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(btnBuscarAtributo))
        );

        jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder("Clasificador"));

        btnBuscarClasificador.setText("Buscar");
        btnBuscarClasificador.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBuscarClasificadorActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addGap(25, 25, 25)
                .addComponent(txtClasificador, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(23, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel8Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btnBuscarClasificador)
                .addGap(39, 39, 39))
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel8Layout.createSequentialGroup()
                .addGap(25, 25, 25)
                .addComponent(txtClasificador, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btnBuscarClasificador)
                .addGap(34, 34, 34))
        );

        jPanel9.setBorder(javax.swing.BorderFactory.createTitledBorder("Rango de Fechas"));

        jLabel3.setText("Inicio");

        jLabel4.setText("Fin");

        btnFechas.setText("Buscar");
        btnFechas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnFechasActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel9Layout.createSequentialGroup()
                                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel3)
                                    .addComponent(jLabel4))
                                .addGap(0, 0, Short.MAX_VALUE))
                            .addGroup(jPanel9Layout.createSequentialGroup()
                                .addGap(0, 44, Short.MAX_VALUE)
                                .addComponent(btnFechas)))
                        .addGap(47, 47, 47))
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(txtFechaFin, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 135, Short.MAX_VALUE)
                            .addComponent(txtFechaInicio, javax.swing.GroupLayout.Alignment.LEADING))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
        );
        jPanel9Layout.setVerticalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(txtFechaInicio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(txtFechaFin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(11, 11, 11)
                .addComponent(btnFechas)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel10.setBorder(javax.swing.BorderFactory.createTitledBorder("Defectos"));

        grupodefectos.add(rdcon);
        rdcon.setText("Con Defecto");

        grupodefectos.add(rdsin);
        rdsin.setText("Sin Defecto");

        jButton6.setText("Buscar");
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(jPanel10);
        jPanel10.setLayout(jPanel10Layout);
        jPanel10Layout.setHorizontalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addGap(18, 18, 18)
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jButton6)
                    .addComponent(rdsin)
                    .addComponent(rdcon))
                .addContainerGap(38, Short.MAX_VALUE))
        );
        jPanel10Layout.setVerticalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(rdcon)
                .addGap(18, 18, 18)
                .addComponent(rdsin)
                .addGap(18, 18, 18)
                .addComponent(jButton6)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        tblPrendas.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null}
            },
            new String [] {
                "Codigo", "Descripcion", "Fecha Adquisicion", "Color", "Numero Usos"
            }
        ));
        jScrollPane1.setViewportView(tblPrendas);

        jButton2.setText("Seleccionar Prenda");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButton4.setText("Calificar Prenda");

        jButton8.setText("Agregar Defecto");

        jButton9.setText("Compartir Prenda");

        jButton10.setText("Enviar a Lavanderia");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(55, 55, 55)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 494, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 89, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addComponent(jButton2)
                        .addGap(54, 54, 54))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jButton10)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jButton9)
                                .addComponent(jButton8)
                                .addComponent(jButton4)))
                        .addGap(52, 52, 52))))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jButton2)
                        .addGap(18, 18, 18)
                        .addComponent(jButton4)
                        .addGap(14, 14, 14)
                        .addComponent(jButton8)
                        .addGap(18, 18, 18)
                        .addComponent(jButton9)
                        .addGap(18, 18, 18)
                        .addComponent(jButton10))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 263, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(36, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Resultados de la Busqueda", jPanel1);

        tblNuevoConjunto.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null}
            },
            new String [] {
                "Codigo", "Descripcion", "Fecha Adquisicion"
            }
        ));
        jScrollPane3.setViewportView(tblNuevoConjunto);

        jButton11.setText("Eliminar prenda");

        jButton12.setText("Guardar conjunto");
        jButton12.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton12ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(36, 36, 36)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(47, 47, 47)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jButton11)
                    .addComponent(jButton12))
                .addContainerGap(165, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(45, 45, 45)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jButton11)
                        .addGap(18, 18, 18)
                        .addComponent(jButton12))
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 227, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(51, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Conjunto", jPanel2);

        jPanel11.setBorder(javax.swing.BorderFactory.createTitledBorder("Compartidas"));

        grupocompartidas.add(rdcompartidas);
        rdcompartidas.setText("Compartidas");

        grupocompartidas.add(rdindividuales);
        rdindividuales.setText("Indivuales");

        jButton7.setText("Buscar");
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel11Layout = new javax.swing.GroupLayout(jPanel11);
        jPanel11.setLayout(jPanel11Layout);
        jPanel11Layout.setHorizontalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addGap(14, 14, 14)
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jButton7)
                    .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(rdindividuales)
                        .addComponent(rdcompartidas)))
                .addContainerGap(32, Short.MAX_VALUE))
        );
        jPanel11Layout.setVerticalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(rdcompartidas)
                .addGap(18, 18, 18)
                .addComponent(rdindividuales)
                .addGap(18, 18, 18)
                .addComponent(jButton7)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Mas o menos usos"));

        grupousados.add(rdmasusados);
        rdmasusados.setText("Mas Usados");

        grupousados.add(rdmenosusados);
        rdmenosusados.setText("Menos Usados");

        btnusos.setText("Buscar");
        btnusos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnusosActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(16, 16, 16)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(btnusos)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(rdmenosusados)
                        .addComponent(rdmasusados)))
                .addContainerGap(46, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(rdmasusados)
                .addGap(18, 18, 18)
                .addComponent(rdmenosusados)
                .addGap(18, 18, 18)
                .addComponent(btnusos)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jPanel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(28, 28, 28)
                .addComponent(jPanel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup()
                .addGap(0, 0, Short.MAX_VALUE)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 822, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(137, 137, 137))
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(59, 59, 59)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 351, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(67, 67, 67))
        );

        jLabel2.setText("Usuario:");

        lblCedulaUs.setText("0103849873");

        lblApodo.setText("Apodo");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addGap(33, 33, 33)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblCedulaUs)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblApodo)
                .addGap(225, 225, 225)
                .addComponent(jLabel1)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(24, 24, 24)
                        .addComponent(jLabel1))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2)
                            .addComponent(lblCedulaUs)
                            .addComponent(lblApodo))))
                .addGap(26, 26, 26)
                .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(16, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        princi =  new Principal();
        princi.setVisible(true);
        this.setVisible(false);
    }//GEN-LAST:event_formWindowClosing

    private void btnBuscarAtributoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBuscarAtributoActionPerformed
        // TODO add your handling code here:
        String cedula = lblCedulaUs.getText();
        if(rdCodigo.isSelected()){
            prenda.setCodigo(Integer.parseInt(txtAtributos.getText()));
            prenda.buscarCodigo(cedula, Integer.parseInt(txtAtributos.getText()));
            insertarPrendaTabla(prenda);
        }
        else if(rdDescripcion.isSelected()){
            prenda.setDescripcion(txtAtributos.getText());
            prenda.buscarDescripcion(cedula, txtAtributos.getText());
            insertarPrendaTabla(prenda);
        }
        else if(rdAdquisicion.isSelected()){
            prenda.setFecha_adquisicion(txtAtributos.getText());
            prenda.buscarFechaAdqui(cedula, txtAtributos.getText());
            insertarPrendaTabla(prenda);
        }
        else{
            JOptionPane.showMessageDialog(null, "Seleccione una opcion e ingrese un dato en el cuadro de texto");
        }
    }//GEN-LAST:event_btnBuscarAtributoActionPerformed

    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
        // TODO add your handling code here:
        login.setId(listaLogin.getId());
        login.buscar();        
        usuario.setCedula(login.getUsu().getCedula());
        usuario.buscar();
        lblCedulaUs.setText(usuario.getCedula());
        lblApodo.setText(usuario.getApodo());
    }//GEN-LAST:event_formWindowOpened

    private void btnBuscarClasificadorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBuscarClasificadorActionPerformed
        // TODO add your handling code here:
        String cedula = lblCedulaUs.getText();
        int id = Integer.parseInt(txtClasificador.getText());
        actualizarPrendaClasificacion(cedula, id);
    }//GEN-LAST:event_btnBuscarClasificadorActionPerformed

    private void btnFechasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFechasActionPerformed
        // TODO add your handling code here:
        String cedula = lblCedulaUs.getText();
        String fecha_inicio = txtFechaInicio.getText();
        String fecha_fin = txtFechaFin.getText();
        actualizarPrendaRangoFechas(cedula, fecha_inicio, fecha_fin);
        
        
    }//GEN-LAST:event_btnFechasActionPerformed

    private void btnusosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnusosActionPerformed
        String cedula = lblCedulaUs.getText();
        if(rdmasusados.isSelected()){       
               actualizarPrendaMasUsos(cedula);                  
        }
        else if(rdmenosusados.isSelected()) { 
            actualizarPrendaMenosUsos(cedula);
        
       
        }
        else{
            JOptionPane.showMessageDialog(null, "Seleccione una opcion e ingrese un dato en el cuadro de texto");
        }
    }//GEN-LAST:event_btnusosActionPerformed

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
       String cedula = lblCedulaUs.getText();
        if(rdcon.isSelected()){       
               actualizarPrendaConDefectos(cedula);                  
        }
        else if(rdsin.isSelected()) { 
            actualizarPrendaSinDefectos(cedula);
        
       
        }
        else{
            JOptionPane.showMessageDialog(null, "Seleccione una opcion e ingrese un dato en el cuadro de texto");
        }
    }//GEN-LAST:event_jButton6ActionPerformed

    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
        String cedula = lblCedulaUs.getText();
        if(rdcompartidas.isSelected()){       
               actualizarPrendaCompatidas(cedula);                  
        }
        else if(rdindividuales.isSelected()) { 
            actualizarPrendaIndividuales(cedula);   
       
        }
        else{
            JOptionPane.showMessageDialog(null, "Seleccione una opcion e ingrese un dato en el cuadro de texto");
        }
    }//GEN-LAST:event_jButton7ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
        int codigo = (Integer)tblPrendas.getValueAt(tblPrendas.getSelectedRow(), 0);
        try {
            Prenda auxpr = prdb.buscar(codigo);
            prendas.add(auxpr);
            actualizarConjuntoPrenda(prendas);
        } catch (SQLException ex) {
            Logger.getLogger(Prendas.class.getName()).log(Level.SEVERE, null, ex);
        }
        
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton12ActionPerformed
        // TODO add your handling code here:
    /*  String nom = JOptionPane.showInputDialog(null, "Ingrese el nombre del Conjunto");
        Conjunto auxcon = new Conjunto();
        auxcon.setDescripcion(nom);
        auxcon.setNumero_usos(0);
        for (int i = 0; i < prendas.size(); i++) {
            Prenda otroPrenda = new Prenda();
            otroPrenda = (Prenda) prendas.get(i);
            cp.setPrenda(prenda);
            cp.getConjunto()
        }*/
    }//GEN-LAST:event_jButton12ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Prendas.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Prendas.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Prendas.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Prendas.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Prendas().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnBuscarAtributo;
    private javax.swing.JButton btnBuscarClasificador;
    private javax.swing.JButton btnFechas;
    private javax.swing.JButton btnusos;
    private javax.swing.ButtonGroup grupoatributos;
    private javax.swing.ButtonGroup grupocompartidas;
    private javax.swing.ButtonGroup grupodefectos;
    private javax.swing.ButtonGroup grupousados;
    private javax.swing.JButton jButton10;
    private javax.swing.JButton jButton11;
    private javax.swing.JButton jButton12;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JButton jButton8;
    private javax.swing.JButton jButton9;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel11;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JLabel lblApodo;
    private javax.swing.JLabel lblCedulaUs;
    private javax.swing.JRadioButton rdAdquisicion;
    private javax.swing.JRadioButton rdCodigo;
    private javax.swing.JRadioButton rdDescripcion;
    private javax.swing.JRadioButton rdcompartidas;
    private javax.swing.JRadioButton rdcon;
    private javax.swing.JRadioButton rdindividuales;
    private javax.swing.JRadioButton rdmasusados;
    private javax.swing.JRadioButton rdmenosusados;
    private javax.swing.JRadioButton rdsin;
    private javax.swing.JTable tblNuevoConjunto;
    private javax.swing.JTable tblPrendas;
    private javax.swing.JTextField txtAtributos;
    private javax.swing.JTextField txtClasificador;
    private javax.swing.JTextField txtFechaFin;
    private javax.swing.JTextField txtFechaInicio;
    // End of variables declaration//GEN-END:variables
}
